package com.mayi.zds_comment.dao;

import com.mayi.zds_comment.entity.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @description:
 * @author: 胡飞
 * @time: 2019/12/24 15:16
 */
public interface GoodsDAO {


    @Insert("insert into zds_goods values(#{goods.id},#{goods.goodsNo},#{goods.name},#{goods.originalPrice},#{goods.salePrice},#{goods.saling},#{goods.stock},#{goods.thumbnail},#{goods.description},#{goods.recomment}," +
            "#{goods.judgeNum},#{goods.average},#{goods.businessId})")
    /**
     * @description: 添加商品，recomment必传，可为空
     * @params: [goods]
     * @return: void
     * @author: 胡飞
     * @time: 2019/12/24 15:34
     */
    public void add(@Param("goods") Goods goods);

    @Delete("delete from zds_goods where id=#{goodsId}")
    /**
     * @description:
     * @params: 商品[id]
     * @return: void
     * @author: 胡飞
     * @time: 2019/12/24 15:37
     */
    public void delete(String goodsId);
    
    @Select("select * from zds_goods where id=#{goodsId}")
    /**
     * @description: 
     * @params: [goodsId]
     * @return: com.mayi.zds.entity.Goods
     * @author: 胡飞
     * @time: 2019/12/24 15:39
     */ 
    public Goods getById(String goodsId);

    @Select("select * form zds_goods where business_id=#{businessId}")
    /**
     * @description: 获取当前店铺所有的商品
     * @params: [businessId]
     * @return: java.util.List<com.mayi.zds.entity.Goods>
     * @author: 胡飞
     * @time: 2019/12/24 15:41
     */
    public List<Goods> getAll(String businessId);

    @Update("update zds_goods set name=#{goods.name},original_price=#{goods.originalPrice}," +
            "sale_price=#{goods.salePrice},saling=#{goods.saling},stock=#{goods.stock},thumbnail=#{goods.thumbnail}," +
            "recommetn=#{goods.recomment},description=#{goods.description}")
    /**
     * @description: 更新部分商品信息
     * @params: [goods]
     * @return: void
     * @author: 胡飞
     * @time: 2019/12/24 15:46
     */
    public void update(@Param("goods") Goods goods);
}
